/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Thuan
 */
@Entity
@Table(name = "SubmittedAssignment")
@NamedQueries({
    @NamedQuery(name = "SubmittedAssignment.findAll", query = "SELECT s FROM SubmittedAssignment s"),
    @NamedQuery(name = "SubmittedAssignment.findBySubmittedAssignmentId", query = "SELECT s FROM SubmittedAssignment s WHERE s.submittedAssignmentId = :submittedAssignmentId"),
    @NamedQuery(name = "SubmittedAssignment.findByUrlFile", query = "SELECT s FROM SubmittedAssignment s WHERE s.urlFile = :urlFile"),
    @NamedQuery(name = "SubmittedAssignment.findByCreatedDate", query = "SELECT s FROM SubmittedAssignment s WHERE s.createdDate = :createdDate"),
    @NamedQuery(name = "SubmittedAssignment.findByIsDownloaded", query = "SELECT s FROM SubmittedAssignment s WHERE s.isDownloaded = :isDownloaded"),
    @NamedQuery(name = "SubmittedAssignment.findByMark", query = "SELECT s FROM SubmittedAssignment s WHERE s.mark = :mark"),
    @NamedQuery(name = "SubmittedAssignment.findByNote", query = "SELECT s FROM SubmittedAssignment s WHERE s.note = :note")})
public class SubmittedAssignment implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "submittedAssignmentId")
    private Integer submittedAssignmentId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 500)
    @Column(name = "urlFile")
    private String urlFile;
    @Basic(optional = false)
    @Column(name = "createdDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "isDownloaded")
    private boolean isDownloaded;
    @Size(max = 5)
    @Column(name = "mark")
    private String mark;
    @Size(max = 2147483647)
    @Column(name = "note")
    private String note;
    @JoinColumn(name = "studentId", referencedColumnName = "studentId")
    @ManyToOne(optional = false)
    private Student studentId;
    @JoinColumn(name = "assignmentId", referencedColumnName = "assignmentId")
    @ManyToOne(optional = false)
    private Assignment assignmentId;

    public SubmittedAssignment() {
    }

    public SubmittedAssignment(Integer submittedAssignmentId) {
        this.submittedAssignmentId = submittedAssignmentId;
    }

    public SubmittedAssignment(Integer submittedAssignmentId, String urlFile, Date createdDate, boolean isDownloaded) {
        this.submittedAssignmentId = submittedAssignmentId;
        this.urlFile = urlFile;
        this.createdDate = createdDate;
        this.isDownloaded = isDownloaded;
    }

    public Integer getSubmittedAssignmentId() {
        return submittedAssignmentId;
    }

    public void setSubmittedAssignmentId(Integer submittedAssignmentId) {
        this.submittedAssignmentId = submittedAssignmentId;
    }

    public String getUrlFile() {
        return urlFile;
    }

    public void setUrlFile(String urlFile) {
        this.urlFile = urlFile;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public boolean getIsDownloaded() {
        return isDownloaded;
    }

    public void setIsDownloaded(boolean isDownloaded) {
        this.isDownloaded = isDownloaded;
    }

    public String getMark() {
        return mark;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public Student getStudentId() {
        return studentId;
    }

    public void setStudentId(Student studentId) {
        this.studentId = studentId;
    }

    public Assignment getAssignmentId() {
        return assignmentId;
    }

    public void setAssignmentId(Assignment assignmentId) {
        this.assignmentId = assignmentId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (submittedAssignmentId != null ? submittedAssignmentId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SubmittedAssignment)) {
            return false;
        }
        SubmittedAssignment other = (SubmittedAssignment) object;
        if ((this.submittedAssignmentId == null && other.submittedAssignmentId != null) || (this.submittedAssignmentId != null && !this.submittedAssignmentId.equals(other.submittedAssignmentId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.app.model.SubmittedAssignment[ submittedAssignmentId=" + submittedAssignmentId + " ]";
    }

}
